#include <iostream>
//#include <Windows.h>
//#include <unistd.h>
#include "ai-test.h"
//#include "gameboard.h"

int main()
{
	Gameboard game;
	game.setup();
	char color;
	char ai_color;
	char r;
	char c;
	char selected_difficulty;
	char selected_difficulty2;
	string winner;
	int row;
	int column;
	bool valid;
	bool black = true;
	int ipip=0;
	int num_games = 0;
	int black_wins = 0;
	int white_wins = 0;
	int tie_wins = 0;

	selected_difficulty = '1';
	selected_difficulty2 = '3';
	num_games = 100;
	
	game.showNextPos();
	game.display();
	
	AIengine test1;
	AIengine test;
	
	int it=0;
		while (it<num_games)
		{
			
			ipip=0;

			while(game.currentColor() == '@')
			{
				//cout << game.currentColor() << "'s turn" << endl << endl;
				//cout << endl << "AI IS THINKING..." << endl;
				test.difficulty_of_the_AI(selected_difficulty,game);
					//Sleep(100);
					game.move((int)test.row,(int)test.column);
					game.showNextPos();
					//game.display();
					ipip=test.count_num_moves(game);

				
			}

			while(game.currentColor() == 'O')
			{
				//cout << game.currentColor() << "'s turn" << endl << endl;
				//cout << endl << "AI IS THINKING..." << endl;
				//cout << "game number = " << it << endl;
				test1.difficulty_of_the_AI(selected_difficulty2,game);
					//Sleep(100);
					game.move((int)test1.row,(int)test1.column);
					game.showNextPos();
					//game.display();
					ipip=ipip+test1.count_num_moves(game);
			}		

			if(ipip==0){
				winner = game.gameOver();
				game.setup();
				game.showNextPos();
				game.display();
				if(winner == "black")
					black_wins++;
				else if(winner == "white")
					white_wins++;
				else
					tie_wins++;
				it++;
				ipip=1;
			}
		}
	cout << "selected_difficulty = " << selected_difficulty << endl;
	cout << "selected_difficulty2 = " << selected_difficulty2 << endl;
	
	cout << "Black won "<< black_wins << "games" << endl;
	cout << "White won "<< white_wins << "games" << endl;
	cout << tie_wins << " Tie games" << endl;
	char t;
	cin >> t;
}
